package com.sheshu.web.controller.user;

import com.sheshu.common.annotation.Log;
import com.sheshu.common.core.controller.BaseController;
import com.sheshu.common.core.domain.AjaxResult;
import com.sheshu.common.core.page.TableDataInfo;
import com.sheshu.common.enums.BusinessType;
import com.sheshu.common.utils.poi.ExcelUtil;
import com.sheshu.user.domain.HeatResidentUsers;
import com.sheshu.user.service.IHeatResidentUsersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 用热用户信息Controller
 * 
 * @author ruoyi
 * @date 2025-01-07
 */
@RestController
@RequestMapping("/user")
public class HeatResidentUsersController extends BaseController
{
    @Resource
    private IHeatResidentUsersService heatResidentUsersService;

    /**
     * 查询用热用户信息列表
     */
    @PreAuthorize("@ss.hasPermi('user:users:list')")
    @GetMapping("/list")
    public TableDataInfo list(HeatResidentUsers heatResidentUsers)
    {
        startPage();
        List<HeatResidentUsers> list = heatResidentUsersService.selectHeatResidentUsersList(heatResidentUsers);
        return getDataTable(list);
    }

    /**
     * 导出用热用户信息列表
     */
    @PreAuthorize("@ss.hasPermi('user:users:export')")
    @Log(title = "用热用户信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HeatResidentUsers heatResidentUsers)
    {
        List<HeatResidentUsers> list = heatResidentUsersService.selectHeatResidentUsersList(heatResidentUsers);
        ExcelUtil<HeatResidentUsers> util = new ExcelUtil<HeatResidentUsers>(HeatResidentUsers.class);
        util.exportExcel(response, list, "用热用户信息数据");
    }

    /**
     * 获取用热用户信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('user:users:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(heatResidentUsersService.selectHeatResidentUsersById(id));
    }

    /**
     * 新增用热用户信息
     */
    @PreAuthorize("@ss.hasPermi('user:users:add')")
    @Log(title = "用热用户信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HeatResidentUsers heatResidentUsers)
    {
        return toAjax(heatResidentUsersService.insertHeatResidentUsers(heatResidentUsers));
    }

    /**
     * 修改用热用户信息
     */
    @PreAuthorize("@ss.hasPermi('user:users:edit')")
    @Log(title = "用热用户信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HeatResidentUsers heatResidentUsers)
    {
        return toAjax(heatResidentUsersService.updateHeatResidentUsers(heatResidentUsers));
    }

    /**
     * 删除用热用户信息
     */
    @PreAuthorize("@ss.hasPermi('user:users:remove')")
    @Log(title = "用热用户信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(heatResidentUsersService.deleteHeatResidentUsersByIds(ids));
    }
}
